﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcmyjobs.Web.admin_type
{
    public partial class Modify : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["adminName"] != null)
                {
                    if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                    {
                        int atid = (Convert.ToInt32(Request.Params["id"]));
                        ShowInfo(atid);
                    }
                }
                else
                {
                    Maticsoft.Common.MessageBox.ResponseScript(this, "alert('请先登陆！');top.location.href='../adminlogin2.aspx'");
                }

            }
        }

        private void ShowInfo(int atid)
        {
            lcmyjobs.BLL.admin_type bll = new lcmyjobs.BLL.admin_type();
            lcmyjobs.Model.admin_type model = bll.GetModel(atid);
            this.lblatid.Text = model.atid.ToString();
            this.txtatname.Text = model.atname;

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtatname.Text.Trim().Length == 0)
            {
                strErr += "网站管理员用户类型不能为空！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int atid = int.Parse(this.lblatid.Text);
            string atname = this.txtatname.Text;


            lcmyjobs.Model.admin_type model = new lcmyjobs.Model.admin_type();
            model.atid = atid;
            model.atname = atname;

            lcmyjobs.BLL.admin_type bll = new lcmyjobs.BLL.admin_type();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "list.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
